package Tset2;

import java.util.Scanner;

public class Demo3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int key = sc.nextInt();
        int added = addLock(key);
        System.out.println(added);
        int removed = removeLock(added);
        System.out.println(removed);
    }
    public static int addLock(int key){
        if(key<0){
            return -1;
        }
        int reverse = 0;
        while((key%10)!=0){
            reverse = reverse*10+(key%10+5)%10;
            key/=10;
        }
        return reverse;
    }
    public static int removeLock(int reverse){
        if(reverse<0){
            return -1;
        }
        int original = 0;
        while((reverse%10)!=0){
            original = original*10+(reverse%10-5);
            reverse/=10;
        }
        return original;
    }
}
